package com.cms.demo.config;

import org.springframework.boot.autoconfigure.web.servlet.error.ErrorViewResolver;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * @author wangning
 * @create 2021-04-26 17:22
 */
@Component
public class MyErrorViewResolver implements ErrorViewResolver {
	@Override
	public ModelAndView resolveErrorView(HttpServletRequest request, HttpStatus status, Map<String, Object> model) {
		ModelAndView modelAndView = new ModelAndView("errorPage");
		modelAndView.addObject("msg", "出错了！！！");
		modelAndView.addAllObjects(model);

		return modelAndView;
	}
}
